package com.neuedu.dao.impl;

import com.neuedu.dao.BaseDao;
import com.neuedu.dao.WorkDocInfoDao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

public class WorkDocInfoDaoImpl extends BaseDao implements WorkDocInfoDao {
    @Override
    public int addWrokDocInfo(List<Map<String, Object>> list, Connection con) throws SQLException {
        String sql = "INSERT INTO workdocinfo(userid,workinfo,workruleid) VALUES(?,?,?)";
        PreparedStatement ps = con.prepareStatement(sql);
        for (Map<String, Object> map : list) {
            ps.setInt(1, Integer.parseInt(map.get("userid").toString()));
            ps.setString(2, map.get("workinfo").toString());
            ps.setInt(3, Integer.parseInt(map.get("workruleid").toString()));
            ps.addBatch();
        }
        return ps.executeUpdate();
    }
}
